const defaultState = {
    value: ''
};

const reducer = (state = defaultState, action) => {
    console.log(state, action);
    let newState = JSON.parse(JSON.stringify(state)); // 深拷贝,不能直接修改state里的数据
    switch (action.type) {
        case 'change_input':
              newState.value=action.value;
              break;
        case 'action':
              newState.value=action.value
            break
        default:

    }
    // if (action.type === 'change_input') {
    //     newState.value = action.value;
    // }
    return newState;
};

export default reducer;
